// 模块化
import {
  reqGetUserInfo
} from '../../api/user.js'
export default {
  namespaced: true,
  state: {
    userinfo: {}
  },
  mutations: {
    setUserInfo (state, userinfo) {
      state.userinfo = userinfo
    }
  },
  getters: {
    // 等同于计算属性,return
    Upic (state) {
      return state.userinfo.username ? state.userinfo.username.charAt(0).toUpperCase() : ''
    }
  },
  actions: {
    // 异步请求-----获取请求后,我们要把数据给state,
    async Agetinfo (context) {
      const res = await reqGetUserInfo()
      // console.log(res, 777)
      context.commit('setUserInfo', res.data.data)
    }
  },
  modules: {}
}
